package timing.jframe4l.api;

import java.util.Map;

import org.springframework.http.MediaType;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import timing.jframe4l.facade.model.Attachment;
import timing.jframe4l.facade.provider.ISysProvider;
import timing.jframe4l.web.base.AbstractController;
import timing.jframe4l.web.utils.WebUtil;


import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 附件表  前端控制器
 * </p>
 *
 * @author Fengxici
 * @since 2017-11-19
 */
@Controller
@RequestMapping("/attachment")
@Api(value = "附件表接口", description = "附件表接口")
public class AttachmentController extends AbstractController<ISysProvider> {
	public String getService() {
		return "attachmentService";
	}

	@RequiresPermissions("attachment.read")
	@PutMapping(value = "/read/list")
	@ApiOperation(value = "查询附件表", produces = MediaType.APPLICATION_JSON_VALUE)
	public Object query(HttpServletRequest request) {
		Map<String, Object> param = WebUtil.getParameter(request);
        ModelMap modelMap = new ModelMap();
		return super.query(modelMap, param);
	}

	@RequiresPermissions("attachment.read")
	@PutMapping(value = "/read/detail")
	@ApiOperation(value = "附件表详情", produces = MediaType.APPLICATION_JSON_VALUE)
	public Object get(HttpServletRequest request) {
		Attachment param = WebUtil.getParameter(request, Attachment.class);
        ModelMap modelMap = new ModelMap();
		return super.get(modelMap, param);
	}

	@PostMapping
	@RequiresPermissions("attachment.update")
	@ApiOperation(value = "修改附件表", produces = MediaType.APPLICATION_JSON_VALUE)
	public Object update(HttpServletRequest request) {
		Attachment param = WebUtil.getParameter(request, Attachment.class);
        ModelMap modelMap = new ModelMap();
		return super.update(modelMap, param);
	}

	@DeleteMapping
	@RequiresPermissions("attachment.delete")
	@ApiOperation(value = "删除附件表", produces = MediaType.APPLICATION_JSON_VALUE)
	public Object delete(HttpServletRequest request) {
		Attachment param = WebUtil.getParameter(request, Attachment.class);
        ModelMap modelMap = new ModelMap();
		return super.delete(modelMap, param);
	}

}